#pragma once
#include "model\BaseModel.h"
#include <sstream>
#include <cctype>

class BaseModel;

class Validator {
public:
  enum ValidatorType { string_length, is_digit, int_range, required, contains_only };

  // Constructors and destructor
  Validator(BaseModel* model);
  virtual ~Validator();

  // Injects a variable and an alias used to referr to the variable
  Validator& Inject(int var, std::string name);
  Validator& Inject(std::string var, std::string name);

  // Adds an error to the model
  void AddError(const std::string errormsg) const;

  // Validators
  Validator& Required();
  Validator& Length(size_t min, size_t max);
  Validator& InRange(int min, int max);
  Validator& Chars(std::string chars);
  Validator& IsAlpha();
  Validator& IsNumeric();
  Validator& IsTrue(bool (*fn)(const char), std::string errormsg);
  

private:
  BaseModel *model_;
  std::string var_;
  std::string name_;
};